package com.loong.web.suppert.intercept.statistic;

import java.lang.reflect.Method;

import javax.servlet.http.HttpServletRequest;

import org.springframework.web.method.HandlerMethod;

import com.loong.tool.lang.Requests;
import com.loong.tool.lang.Requests.Env;

/**
 * 统计对象
 *
 * @author 张成轩
 */
public class StatisticVo {

	private String name;
	private Env env;
	private String ip;
	private String url;
	private String param;
	private Class<?> clas;
	private Method method;
	private long time;

	/**
	 * 构造方法
	 * 
	 * @param statistic 注释
	 * @param request 请求
	 * @param handler 处理方法
	 */
	public StatisticVo(Statistic statistic, HttpServletRequest request, HandlerMethod handler) {

		this.name = statistic.value();
		env = Requests.getEnv(request);
		ip = Requests.getIp(request);
		url = request.getServletPath();
		param = request.getQueryString();
		clas = handler.getBean().getClass();
		method = handler.getMethod();
		time = System.currentTimeMillis();
	}

	/**
	 * @return 名称
	 */
	public String getName() {

		return name;
	}

	/**
	 * @return 请求环境
	 */
	public Env getEnv() {

		return env;
	}

	/**
	 * @return ip
	 */
	public String getIp() {

		return ip;
	}

	/**
	 * @return 访问路径
	 */
	public String getUrl() {

		return url;
	}

	/**
	 * @return 访问参数
	 */
	public String getParam() {

		return param;
	}

	/**
	 * @return 调用类
	 */
	public Class<?> getClas() {

		return clas;
	}

	/**
	 * @return 调用方法
	 */
	public Method getMethod() {

		return method;
	}

	/**
	 * @return 调用时间
	 */
	public long getTime() {

		return time;
	}
}
